package cn.com.huzo.repository.inventory.impl;

import cn.com.huzo.model.entities.inventory.StockInLinesEntity;
import cn.com.huzo.model.entities.inventory.StockInLinesPoLinesEntity;
import cn.com.huzo.repository.inventory.StockInLinesPoLinesRepository;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 入库单-引入的采购订单明细数据访问对象。
 *
 * @author 吴旭
 */
@Repository("StockInLinesPoLinesRepository")
public class StockInLinesPoLinesRepositoryImpl extends GenericRepositoryImpl<StockInLinesPoLinesEntity, String>
        implements StockInLinesPoLinesRepository {

    private final String namespace = "cn.com.huzo.repository.inventory.StockInLinesPoLinesRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public StockInLinesPoLinesRepositoryImpl() {
        super(StockInLinesPoLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insert(Long headerId, List<String> poLinesIdList, Long userId) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("PoLinesIdList", poLinesIdList);
        criterion.put("CreatedBy", userId);
        criterion.put("UpdatedBy", userId);

        // 影响的行数
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer fetchForCount(Map<String, Object> criterion) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForCount"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<StockInLinesPoLinesEntity> fetchForPage(Map<String, Object> criterion) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchForPage"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer update(List<StockInLinesPoLinesEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "update"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateStockInQuantity(StockInLinesEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateStockInQuantity"), instance);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer updateStockInQuantity02(StockInLinesEntity instance) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "updateStockInQuantity02"), instance);
    }
}
